```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring依赖注入注解对比 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .code-block {
            font-family: 'Courier New', Courier, monospace;
            background-color: #f8f9fa;
            border-left: 4px solid #667eea;
        }
        .diff-item {
            border-bottom: 1px solid #eaeaea;
            padding-bottom: 1.5rem;
            margin-bottom: 1.5rem;
        }
        .diff-item:last-child {
            border-bottom: none;
        }
        .feature-icon {
            width: 40px;
            height: 40px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            margin-right: 1rem;
        }
        .mermaid {
            background-color: #fff;
            padding: 1.5rem;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-4xl text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">Spring依赖注入注解对比</h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">深入解析@Autowired与@Resource的核心差异</p>
            <div class="flex justify-center space-x-4">
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm">Spring框架</span>
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm">Java EE</span>
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm">依赖注入</span>
            </div>
        </div>
    </section>

    <main class="container mx-auto max-w-4xl px-4 md:px-0 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <p class="text-lg text-gray-700 mb-6 leading-relaxed">
                在现代Java开发中，依赖注入是实现松耦合设计的关键技术。<code class="bg-gray-100 px-2 py-1 rounded">@Autowired</code>和<code class="bg-gray-100 px-2 py-1 rounded">@Resource</code>都是常用的依赖注入注解，它们看似相似但在实现机制和应用场景上存在重要差异。本文将深入剖析这两个注解的六大核心区别。
            </p>
        </section>

        <!-- Key Differences -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 font-serif flex items-center">
                <span class="feature-icon bg-blue-100 text-blue-600">
                    <i class="fas fa-balance-scale"></i>
                </span>
                核心差异对比
            </h2>

            <div class="bg-white rounded-xl shadow-md p-6">
                <div class="diff-item">
                    <h3 class="text-xl font-semibold mb-3 text-blue-600">1. 来源不同</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div class="bg-blue-50 p-4 rounded-lg">
                            <h4 class="font-medium mb-2 flex items-center">
                                <i class="fas fa-leaf text-blue-500 mr-2"></i>
                                @Autowired
                            </h4>
                            <p>Spring框架提供的注解，是Spring生态的核心组成部分</p>
                        </div>
                        <div class="bg-green-50 p-4 rounded-lg">
                            <h4 class="font-medium mb-2 flex items-center">
                                <i class="fas fa-coffee text-green-500 mr-2"></i>
                                @Resource
                            </h4>
                            <p>Java EE标准注解，遵循JSR-250规范，具有更广泛的兼容性</p>
                        </div>
                    </div>
                </div>

                <div class="diff-item">
                    <h3 class="text-xl font-semibold mb-3 text-blue-600">2. 注入方式</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div class="bg-blue-50 p-4 rounded-lg">
                            <h4 class="font-medium mb-2">按类型注入 (byType)</h4>
                            <p>自动匹配与属性类型一致的Bean，当存在多个匹配时需配合<code class="bg-blue-100 px-1 rounded">@Qualifier</code>使用</p>
                        </div>
                        <div class="bg-green-50 p-4 rounded-lg">
                            <h4 class="font-medium mb-2">按名称注入 (byName)</h4>
                            <p>根据Bean的名称匹配，可通过name属性指定，无需额外注解</p>
                        </div>
                    </div>
                </div>

                <div class="diff-item">
                    <h3 class="text-xl font-semibold mb-3 text-blue-600">3. 作用域差异</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div class="bg-blue-50 p-4 rounded-lg">
                            <h4 class="font-medium mb-2">@Autowired</h4>
                            <ul class="list-disc pl-5 space-y-1">
                                <li>构造器注入</li>
                                <li>属性注入</li>
                                <li>Setter方法注入</li>
                            </ul>
                        </div>
                        <div class="bg-green-50 p-4 rounded-lg">
                            <h4 class="font-medium mb-2">@Resource</h4>
                            <ul class="list-disc pl-5 space-y-1">
                                <li>属性注入</li>
                                <li>Setter方法注入</li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="diff-item">
                    <h3 class="text-xl font-semibold mb-3 text-blue-600">4. 容器兼容性</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div class="bg-blue-50 p-4 rounded-lg">
                            <h4 class="font-medium mb-2">Spring专属</h4>
                            <p>仅适用于Spring容器，迁移到其他IOC容器时需要修改代码</p>
                        </div>
                        <div class="bg-green-50 p-4 rounded-lg">
                            <h4 class="font-medium mb-2">通用标准</h4>
                            <p>符合JSR-250标准，所有支持Java EE规范的容器均可使用</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visual Comparison -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 font-serif flex items-center">
                <span class="feature-icon bg-purple-100 text-purple-600">
                    <i class="fas fa-project-diagram"></i>
                </span>
                核心概念关系图
            </h2>
            <div class="mermaid">
                flowchart TD
                    A[依赖注入注解] --> B[@Autowired]
                    A --> C[@Resource]
                    
                    B --> D[Spring专有]
                    B --> E[按类型注入]
                    B --> F[需配合@Qualifier]
                    B --> G[支持构造器注入]
                    
                    C --> H[JavaEE标准]
                    C --> I[按名称注入]
                    C --> J[无需额外注解]
                    C --> K[不支持构造器注入]
            </div>
        </section>

        <!-- Code Examples -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 font-serif flex items-center">
                <span class="feature-icon bg-yellow-100 text-yellow-600">
                    <i class="fas fa-code"></i>
                </span>
                示例代码对比
            </h2>
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="bg-blue-600 text-white px-4 py-3">
                        <h3 class="font-medium">@Autowired 示例</h3>
                    </div>
                    <div class="p-4 code-block">
                        <pre><code>@Component
public class MyClass {
    private MyDependency myDependency;

    @Autowired
    public MyClass(MyDependency myDependency) {
        this.myDependency = myDependency;
    }

    @Autowired
    @Qualifier("specialBean")
    private AnotherDependency anotherDep;
}</code></pre>
                    </div>
                </div>
                
                <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="bg-green-600 text-white px-4 py-3">
                        <h3 class="font-medium">@Resource 示例</h3>
                    </div>
                    <div class="p-4 code-block">
                        <pre><code>@Component
public class MyClass {
    @Resource(name = "myDependency")
    private MyDependency myDependency;

    @Resource
    public void setAnotherDep(AnotherDependency dep) {
        this.anotherDep = dep;
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary -->
        <section class="bg-white rounded-xl shadow-md p-6 mb-16">
            <h2 class="text-3xl font-bold mb-6 font-serif flex items-center">
                <span class="feature-icon bg-red-100 text-red-600">
                    <i class="fas fa-check-circle"></i>
                </span>
                总结与选择建议
            </h2>
            
            <div class="space-y-4">
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center mt-1 mr-3">
                        <i class="fas fa-check text-blue-500"></i>
                    </div>
                    <div>
                        <h4 class="font-medium text-lg">使用@Autowired的场景</h4>
                        <p class="text-gray-700">当项目完全基于Spring框架，需要构造器注入或明确类型安全性时优先使用。</p>
                    </div>
                </div>
                
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-10 w-10 rounded-full bg-green-100 flex items-center justify-center mt-1 mr-3">
                        <i class="fas fa-check text-green-500"></i>
                    </div>
                    <div>
                        <h4 class="font-medium text-lg">使用@Resource的场景</h4>
                        <p class="text-gray-700">当需要按名称注入、考虑未来容器迁移或遵循Java EE标准时优先使用。</p>
                    </div>
                </div>
                
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-10 w-10 rounded-full bg-purple-100 flex items-center justify-center mt-1 mr-3">
                        <i class="fas fa-lightbulb text-purple-500"></i>
                    </div>
                    <div>
                        <h4 class="font-medium text-lg">最佳实践</h4>
                        <p class="text-gray-700">在单一项目中保持一致性，避免混用两种注解。Spring项目中推荐优先使用@Autowired以利用其完整功能。</p>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="container mx-auto max-w-4xl px-4 text-center">
            <h3 class="text-xl font-medium mb-2 text-white">技术小馆</h3>
            <p class="mb-4">分享前沿技术，探索编程之美</p>
            <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition-colors" target="_blank">
                <i class="fas fa-external-link-alt mr-1"></i> www.yuque.com/jtostring
            </a>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```